﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using GameEngine.View.Components;

namespace SilverlightClientEngine.View.Components
{
    public partial class MapNavigator : UserControl, IMapNavigator<int, FrameworkElement>
    {
        public const string NAVIGATEUPBUTTON = "up";
        public const string NAVIGATEDOWNBUTTON = "down";
        public const string NAVIGATELEFTBUTTON = "left";
        public const string NAVIGATERIGHTBUTTON = "right";

        public event Action<Point> OnMapNavigate;

        public MapNavigator()
        {
            InitializeComponent();

            navigateUpButton.Tag = NAVIGATEUPBUTTON;
            navigateLeftButton.Tag = NAVIGATELEFTBUTTON;
            navigateRightButton.Tag = NAVIGATERIGHTBUTTON;
            navigateDownButton.Tag = NAVIGATEDOWNBUTTON;
        }

        public void Initialize()
        {
            
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button b = (Button)sender;
            switch (b.Tag as string)
            {
                case NAVIGATEDOWNBUTTON:
                    OnMapNavigate(new Point(0, -1));
                    break;
                case NAVIGATEUPBUTTON:
                    OnMapNavigate(new Point(0, 1));
                    break;
                case NAVIGATERIGHTBUTTON:
                    OnMapNavigate(new Point(1, 0));
                    break;
                case NAVIGATELEFTBUTTON:
                    OnMapNavigate(new Point(-1, 0));
                    break;
            }
        }
    }
}
